package com.rub.android.ui.activity

import android.os.Bundle
import android.widget.ListView
import androidx.appcompat.app.AppCompatActivity
import com.rub.android.R
import com.rub.android.adapter.ListViewAdapter
import com.rub.android.model.ListViewModel
import com.rub.android.utils.logI


class ListViewActivity : AppCompatActivity() {

    private var dataList: MutableList<ListViewModel> = ArrayList()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_list_view)

        for (i in 1..100) {
            dataList.apply {
                add(ListViewModel("蹭蹭${i}", "蹭蹭喜欢旅游", R.drawable.rub))
            }
        }

        var listView = findViewById<ListView>(R.id.lv_id)
        listView.adapter = ListViewAdapter(dataList, this)

        listView.setOnItemClickListener { parent, view, position, id ->
            logI("ListViewActivity","点击位置:${position}")
        }

    }

}